package com.thinkgem.jeesite.modules.gen.parse.impl;

import com.thinkgem.jeesite.common.utils.Exceptions;
import com.thinkgem.jeesite.modules.gen.parse.IParse;
import freemarker.template.Configuration;
import freemarker.template.Template;

import java.io.StringReader;
import java.io.StringWriter;
import java.util.Map;

/**
 * @Author:Kongxiangsheng
 * @DesCription:
 * @Date:Created in 19:56 2018/11/5
 * @Modified By:
 */
public class FreeMarkerParseImpl implements IParse {
    @Override
    public String parse(String templateContent, Map<String, ?> model) {
        try {
            StringWriter result = new StringWriter();
            Template t = new Template("name", new StringReader(templateContent), new Configuration());
            t.process(model, result);
            return result.toString();
        } catch (Exception e) {
            throw Exceptions.unchecked(e);
        }
    }
}
